from flask import render_template, request
from app import app
from app.models.user import User


@app.route('/users')
def users():
    # 此处写SQL
    user = User.query.filter_by(userid='1').first()

    return render_template('users.html', user=user)


# 测试用
@app.route('/add_user', methods=['GET'])
def add_user():
    name = request.form['name']
    userid = request.form['userid']
    user = User(name=name, userid=userid)
    db.session.add(user)
    db.session.commit()
    # return redirect(url_for('users'))
    return f"接收到的 userid 是：{userid}，name 是：{name}"
